package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.myenum.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Select("select * from category where type = #{type}")
    public List<Category> selectByType(Integer type);


    public List<Category> selectByPage(CategoryPageQueryDTO categoryPageQueryDTO);


    @AutoFill(OperationType.UPDATE)
    void updateById(Category category);

    @AutoFill(OperationType.INSERT)
    @Insert("insert into category(type,name,sort,status,create_time,update_time,create_user,update_user) " +
            "values(#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void insert(Category category);

    @Delete("delete from category where id = #{id}")
    void deleteById(Integer id);



    String getNameById(Long categoryId);

    List<Category> selectAll();

}
